home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT28.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.4 KB  |  72 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 28                         
  5.                                                                               
  6.  Demonstrates wpan.                                                                
  7.  Since 320x200x256 doesn't support multiple pages, the vertical             
  8.  lines you might see when the screen scrolls down is just what is           
  9.  in memory after the VGA screen buffer. Do not be alarmed.                  
  10.                                                                               
  11.  *** PROJECT ***                                                             
  12.  This program requires the file WGT5_WC.LIB to be linked.                    
  13.                                                                               
  14.  *** DATA FILES ***                                                          
  15.  NONE                                                                        
  16.                                                            WATCOM C++ VERSION 
  17. ==============================================================================
  18. */
  19.  
  20. #include <conio.h>
  21. #include <wgt5.h>
  22.  
  23. void main(void)
  24. {
  25.   short i;
  26.   short oldmode;
  27.  
  28.   if ( !vgadetected () )
  29.   {
  30.     printf("Error - VGA card required for any WGT program.\n");
  31.     exit (0);
  32.   }
  33.   printf ("WGT Example #28\n\n");
  34.   printf ("VGA Hardware panning is demonstrated using WPAN.\n");
  35.   printf ("Press a key to end the program at any time.\n");
  36.   printf ("\n\nPress any key to continue.\n");
  37.   getch ();
  38.  
  39.  
  40.   oldmode = wgetmode ();         /* Gets the current mode */
  41.   vga256 ();                     /* Initialize graphics mode */
  42.  
  43.   for (i = 1; i < 200; i++)      /* Draw a background for screen */
  44.   {
  45.     wsetcolor (i);
  46.     wline (0, 0, 319, i);
  47.     wsetcolor (200 - i);
  48.     wline (319, 199, 0, i);
  49.   }
  50.  
  51.   do
  52.   {
  53.     for (i = 0; i < 100; i++)       /* Pan down a row at a time */
  54.     {
  55.       wpan (i * 320);
  56.       delay (20);
  57.       if (kbhit ())
  58.         break;
  59.     }
  60.     for (i = 0; i < 50; i++)        /* Make the screen shake */
  61.     {
  62.       wpan (rand () % 10);
  63.       delay (40);
  64.       if (kbhit ())
  65.         break;
  66.     }
  67.   } while (!kbhit ());
  68.  
  69.   getch ();
  70.   wsetmode (oldmode);            /* Restore initial video mode */
  71. }
  72.